import { Method } from '../method'
import service from '../service'

export default {
  // 新领审核列表
  querySealApplyByAgent(
    pageIndex: number,
    pageNumber: number,
    sealName: string,
    sealApplyStatus: number = 0,
    sealType: number,
    sealApplyType: number,
    sealApplyId: string
  ) {
    return service({
      url: `/seal/rest/sealApply/querySealApplyByAgent`,
      method: Method.POST,
      body: {
        pageIndex,
        pageNumber,
        sealApplyStatus,
        sealName,
        sealType,
        sealApplyType,
        sealApplyId,
      },
    })
  },
  queryOrg(name: string, pageIndex: number = 1, pageNumber: number = 30) {
    // 查询组织机构
    return service({
      url: `/seal/rest/organize/getOrganizes`,
      method: Method.POST,
      body: {
        name,
        pageIndex,
        pageNumber,
      },
    })
  },
  queryAuditOrg(organizeUUID: string) {
    // 查询上级审批机构
    return service({
      url: `/seal/rest/organize/getParents`,
      method: Method.POST,
      body: {
        organizeUUID,
      },
    })
  },
  sealApply(
    applyOrganizeUuid: string,
    confirmOrganizeUuid: string,
    sealApplyFileKey: string,
    sealName: string,
    sealType: number | null,
    sealUseType: number | null,
    agentLicenseNumber: string,
    agentName: string,
    agentMobile: string,
    organizeLicenseNumber: string,
    organizeName: string,
    auditOrganizeLicenseNumber: string,
    auditOrganizeName: string,
    agentLicenseType?: number,
    organizeAdministrationLevel?: number,
    organizeLicenseType?: number,
    organizeType?: number,
    auditOrganizeLicenseType?: number,
    sealApplyId?: number,
    sealUseTime?: number,
    licenseNumberSource?: number,
    licenseNumberFileKey?: string,
    sealElectronicPicFileKey?: string,
    sealElectronicPicSubmitType?: number | null
  ) {
    // 仅保存
    return service({
      url: `/seal/rest/sealApply/sealApply`,
      method: Method.POST,
      body: {
        applyOrganizeUuid,
        confirmOrganizeUuid,
        sealApplyFileKey,
        sealName,
        sealType,
        sealUseType,
        sealApplyId,
        agentLicenseNumber,
        agentLicenseType,
        agentName,
        agentMobile,
        organizeAdministrationLevel,
        organizeLicenseNumber,
        organizeLicenseType,
        organizeName,
        organizeType,
        auditOrganizeLicenseType,
        auditOrganizeLicenseNumber,
        auditOrganizeName,
        sealUseTime,
        licenseNumberSource,
        licenseNumberFileKey,
        sealElectronicPicFileKey,
        sealElectronicPicSubmitType,
      },
    })
  },
  sealApplySaveAndSubmit(
    applyOrganizeUuid: string,
    confirmOrganizeUuid: string,
    sealApplyFileKey: string,
    sealName: string,
    sealType: number | null,
    sealUseType: number | null,
    agentLicenseNumber: string,
    agentName: string,
    agentMobile: string,
    organizeLicenseNumber: string,
    organizeName: string,
    auditOrganizeLicenseNumber: string,
    auditOrganizeName: string,
    agentLicenseType?: number,
    organizeAdministrationLevel?: number,
    organizeLicenseType?: number,
    organizeType?: number,
    auditOrganizeLicenseType?: number,
    sealApplyId?: number
  ) {
    // 保存并提交
    return service({
      url: `/seal/rest/sealApply/sealApplySaveAndSubmit`,
      method: Method.POST,
      body: {
        applyOrganizeUuid,
        confirmOrganizeUuid,
        sealApplyFileKey,
        sealName,
        sealType,
        sealUseType,
        sealApplyId,
        agentLicenseNumber,
        agentLicenseType,
        agentName,
        agentMobile,
        organizeAdministrationLevel,
        organizeLicenseNumber,
        organizeLicenseType,
        organizeName,
        organizeType,
        auditOrganizeLicenseType,
        auditOrganizeLicenseNumber,
        auditOrganizeName,
      },
    })
  },
  sealApplySubmit(sealApplyId: number) {
    // 提交
    return service({
      url: `/seal/rest/sealApply/sealApplySubmit`,
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  querySealApplyDetail(sealApplyId: number) {
    // 申请详情
    return service({
      url: `/seal/rest/sealApply/querySealApplyDetail`,
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  sealList(
    pageIndex: number,
    pageNumber: number,
    sealName: string,
    sealStatus: number = 0,
    sealType: number
  ) {
    return service({
      url: `/seal/rest/seal/seallist`,
      method: Method.POST,
      body: {
        pageIndex,
        pageNumber,
        sealStatus,
        sealName,
        sealType,
      },
    })
  },
  sealDetail(sealSn: string) {
    return service({
      url: `/seal/rest/seal/querySealDetail`,
      method: Method.POST,
      body: {
        sealSn,
      },
    })
  },
  deleteApply(sealApplyId: number) {
    return service({
      url: `/seal/rest/sealApply/deleteSealApply`,
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },

  revokeApplyCheck(sealSn: string) {
    // 检查是否存在吊销申请
    return service({
      url: `/seal/rest/sealApply/revokeApplyCheck`,
      method: Method.POST,
      body: {
        sealSn,
      },
    })
  },
  revokeSealApply(
    sealSn: string,
    applyReason: string,
    sealApplyId?: number,
    sealApplyFileKey?: string
  ) {
    // 吊销仅保存
    return service({
      url: `/seal/rest/sealApply/revokeSealApply`,
      method: Method.POST,
      body: {
        sealSn,
        applyReason,
        sealApplyId,
        sealApplyFileKey,
      },
    })
  },
  revokeSealApplySaveAndSubmit(
    sealSn: string,
    applyReason: string,
    sealApplyId?: number,
    sealApplyFileKey?: string
  ) {
    // 吊销保存并提交
    return service({
      url: `/seal/rest/sealApply/revokeSealApplySaveAndSubmit`,
      method: Method.POST,
      body: {
        sealSn,
        applyReason,
        sealApplyId,
        sealApplyFileKey,
      },
    })
  },

  loseSealApply(sealSn: string, applyReason: string) {
    return service({
      url: `/seal/rest/sealApply/loseSealApply`,
      method: Method.POST,
      body: {
        sealSn,
        applyReason,
      },
    })
  },

  restoreSealApply(sealSn: string) {
    return service({
      url: `/seal/rest/sealApply/restoreSealApply`,
      method: Method.POST,
      body: {
        sealSn,
      },
    })
  },

  sealRecall(sealApplyId: number) {
    return service({
      url: `/seal/rest/sealApply/sealRecall`,
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },

  sealRefund(sealApplyId: number, reasonType: number, otherReason: string) {
    console.log(8866)

    return service({
      url: `/seal/rest/sealApply/sealRecall`,
      method: Method.POST,
      body: {
        sealApplyId,
        otherReason,
        reasonType,
      },
    })
  },
  resetSealApply(
    sealSn: string,
    sealName: string,
    confirmOrganizeUuid: string,
    sealApplyId?: number,
    sealApplyFileKey?: string
  ) {
    return service({
      url: `/seal/rest/sealApply/resetSealApply`,
      method: Method.POST,
      body: {
        sealApplyId,
        sealSn,
        confirmOrganizeUuid,
        sealApplyFileKey,
        sealName,
      },
    })
  },
  resetSealApplySaveAndSubmit(
    sealSn: string,
    sealName: string,
    confirmOrganizeUuid: string,
    sealApplyId?: number,
    sealApplyFileKey?: string
  ) {
    return service({
      url: `/seal/rest/sealApply/resetSealApplySaveAndSubmit`,
      method: Method.POST,
      body: {
        sealApplyId,
        sealSn,
        confirmOrganizeUuid,
        sealApplyFileKey,
        sealName,
      },
    })
  },
  reissueSealApplySaveAndSubmit(
    sealSn: string,
    applyReason: string,
    sealApplyId?: number
  ) {
    return service({
      url: `/seal/rest/sealApply/reissueSealApplySaveAndSubmit`,
      method: Method.POST,
      body: {
        sealSn,
        applyReason,
        sealApplyId,
      },
    })
  },
  createOrder(data: any) {
    return service({
      url: `/seal/rest/payOrder/createPayOrder`,
      method: Method.POST,
      body: {
        ...data,
      },
    })
  },
  querySealApplyPayOrderInfo(sealApplyId: number) {
    return service({
      url: `/seal/rest/sealApply/querySealApplyPayOrderInfo`,
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  finishQRCodePayOrder(sealApplyId: number, partnerOrderNo: string) {
    return service({
      url: `/seal/rest/sealApply/finishQRCodePayOrder`,
      method: Method.POST,
      body: {
        sealApplyId,
        partnerOrderNo,
      },
    })
  },
  sealApplyUnifiedSubmit(sealApplyId: number) {
    // 统一付费的提交审核
    return service({
      url: `/seal/rest/sealApply/sealApplyUnifiedSubmit`,
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  // 根据当前用户获取所属印章列表
  queryMySeals(data: any) {
    return service({
      url: '/seal/rest/seal/queryMySeals',
      method: Method.POST,
      body: data,
    })
  },
  sealApplyPicSubmit(sealApplyFileKey: string, sealApplyId: number) {
    return service({
      url: '/seal/rest/sealApply/sealApplyPicSubmit',
      method: Method.POST,
      body: {
        sealApplyId,
        sealApplyFileKey,
      },
    })
  },
  querySealApplyPayPreOrderInfo(sealApplyId: number) {
    return service({
      url: '/seal/rest/payOrder/querySealApplyPayPreOrderInfo',
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  receiptConfirm(sealApplyId: number) {
    return service({
      url: '/seal/rest/sealApply/receiptConfirm',
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  checkSealNameRepeat({ sealApplyId, sealName }: any) {
    return service({
      url: '/seal/rest/sealApply/checkSealNameRepeat',
      method: Method.POST,
      body: {
        sealApplyId,
        sealName,
      },
    })
  },
  querySealApplyOps(sealApplyId: number) {
    return service({
      url: '/seal/rest/sealApply/querySealApplyOps',
      method: Method.POST,
      body: {
        sealApplyId,
      },
    })
  },
  cancelApplyManager(data: any) {
    return service({
      url: '/seal/rest/apply/revokeApplyManager',
      method: Method.POST,
      body: data,
    })
  },
  queryChildAndSealCount(data: any) {
    return service({
      url: '/seal/rest/apply/queryChildAndSealCount',
      method: Method.POST,
      body: data,
    })
  },
  createElectronicSealTask(data: any) {
    return service({
      url: '/seal/rest/sealApply/createElectronicSealTask',
      method: Method.POST,
      body: data,
    })
  },
  queryElectronicSealPic(data: any) {
    return service({
      url: '/seal/rest/sealApply/queryElectronicSealPic',
      method: Method.POST,
      body: data,
    })
  },
  submitSealElectronicPic(data: any) {
    return service({
      url: '/seal/rest/sealApply/submitSealElectronicPic',
      method: Method.POST,
      body: data,
    })
  },
}
